package com.yanqu.road.entity.activity.tonbingchannel.data;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.DataStatus;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@FieldTypeAnnotation(tableName = "t_c_tonbing_user_data")
public class ChannelTonBingUserData extends DataObject {

    @FieldTypeAnnotation(desc = "活动ID", select = true, update = true)
    private int activityId;
    @FieldTypeAnnotation(desc = "玩家ID", update = true)
    private long userId;
    private long serverId;
    private int channelId;

    @FieldTypeAnnotation(desc = "商会ID，来自unionJoin")
    private String unionUid = "";
    @FieldTypeAnnotation(desc = "阵营，不为0才有资格")
    private int campId;

    @FieldTypeAnnotation(desc = "门客数据")
    private Map<Integer, ChannelTonBingPatrons> patronsMap = new ConcurrentHashMap<>();
    @FieldTypeAnnotation(desc = "天赋加成带兵上限")
    private List<Long> soldierAddition = new ArrayList<>();

    @FieldTypeAnnotation(desc = "队伍数据")
    private Map<Integer, ChannelTonBingTeam> teamMap = new ConcurrentHashMap<>();

    @FieldTypeAnnotation(desc = "兵营数据")
    private ChannelTonBingBarracks barracks = new ChannelTonBingBarracks();

    @FieldTypeAnnotation(desc = "npc事件重置时间")
    private long eventResetTime;
    @FieldTypeAnnotation(desc = "npc事件今日生成个数")
    private long eventTodayCount;
    @FieldTypeAnnotation(desc = "npc事件数据：位置，事件ID")
    private Map<Integer, Integer> eventMap = new ConcurrentHashMap<>();

    @FieldTypeAnnotation(desc = "巅峰统兵变成四个城主了，有可能有玩家被任命两次")
    private Map<Integer,Integer> positionMap = new ConcurrentHashMap<>();

    @FieldTypeAnnotation(desc = "累计了多少银两还没领")
    private Map<Long, BigInteger> posAddSilverMap = new ConcurrentHashMap<>();
    @FieldTypeAnnotation(desc = "上一次计算增加银两时间")
    private long posAddSilverTime;

    @FieldTypeAnnotation(desc = "战功")
    private long zhanGong;
    @FieldTypeAnnotation(desc = "战功每一场")
    private Map<Integer,Long> zhanGongMap = new ConcurrentHashMap();
    @FieldTypeAnnotation(desc = "战功变化时间")
    private long zhanGongTime;

    @FieldTypeAnnotation(desc = "求援时间")
    private long needHelpTime;

    @FieldTypeAnnotation(desc = "红点")
    private Map<Integer, Long> redDotMap = new ConcurrentHashMap<>();

    @FieldTypeAnnotation(desc = "马")
    private int horseId;

    @FieldTypeAnnotation(desc = "引导标志")
    private int guide;

    @FieldTypeAnnotation(desc = "累计(上缴/收取)职位银两")
    private BigInteger totalPosSilver = BigInteger.ZERO;

    // 不入库
    private long lastSyncPatronsTime;
    private long lastReqTime;

    // =============================

    public ChannelTonBingUserData() {
    }

    public static ChannelTonBingUserData initChannelTonBingUserData(int activityId, long userId) {
        ChannelTonBingUserData crossTonBingUserData = new ChannelTonBingUserData();
        crossTonBingUserData.setActivityId(activityId);
        crossTonBingUserData.setUserId(userId);
        //每个玩家五个队伍？
        for (int i = 1; i <= 5; i++) {
            crossTonBingUserData.getTeamMap().put(i, new ChannelTonBingTeam(userId, i));
        }
        crossTonBingUserData.setHorseId(1);
        crossTonBingUserData.setInsertOption();
        return crossTonBingUserData;
    }

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        if (this.activityId != activityId) {
            this.activityId = activityId;
            setOp(DataStatus.Update);
        }
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        if (this.userId != userId) {
            this.userId = userId;
            setOp(DataStatus.Update);
        }
    }

    public String getUnionUid() {
        return unionUid;
    }

    public void setUnionUid(String unionUid) {
        if (unionUid == null) {
            return;
        }
        if (this.unionUid == null || !this.unionUid.equals(unionUid)) {
            this.unionUid = unionUid;
            setOp(DataStatus.Update);
        }
    }

    public int getCampId() {
        return campId;
    }

    public void setCampId(int campId) {
        if (this.campId != campId) {
            this.campId = campId;
            setOp(DataStatus.Update);
        }
    }

    public Map<Integer, ChannelTonBingPatrons> getPatronsMap() {
        return patronsMap;
    }

    public void setPatronsMap(Map<Integer, ChannelTonBingPatrons> patronsMap) {
        if (null == patronsMap) {
            return;
        }
        this.patronsMap = patronsMap;
        setOp(DataStatus.Update);
    }

    public Map<Integer, ChannelTonBingTeam> getTeamMap() {
        return teamMap;
    }

    public void setTeamMap(Map<Integer, ChannelTonBingTeam> teamMap) {
        if (null == teamMap) {
            return;
        }
        this.teamMap = teamMap;
        setOp(DataStatus.Update);
    }

    public ChannelTonBingBarracks getBarracks() {
        return barracks;
    }

    public void setBarracks(ChannelTonBingBarracks barracks) {
        if (null == barracks) {
            return;
        }
        this.barracks = barracks;
        setOp(DataStatus.Update);
    }

    public long getEventResetTime() {
        return eventResetTime;
    }

    public void setEventResetTime(long eventResetTime) {
        if (this.eventResetTime != eventResetTime) {
            this.eventResetTime = eventResetTime;
            setOp(DataStatus.Update);
        }
    }

    public long getEventTodayCount() {
        return eventTodayCount;
    }

    public void setEventTodayCount(long eventTodayCount) {
        if (this.eventTodayCount != eventTodayCount) {
            this.eventTodayCount = eventTodayCount;
            setOp(DataStatus.Update);
        }
    }

    public Map<Integer, Integer> getEventMap() {
        return eventMap;
    }

    public void setEventMap(Map<Integer, Integer> eventMap) {
        if (null == eventMap) {
            return;
        }
        this.eventMap = eventMap;
        setOp(DataStatus.Update);
    }

    public int getPositionId() {
        return 0;
    }

    public Map<Integer, Integer> getPositionMap() {
        return positionMap;
    }

    public void setPositionMap(Map<Integer, Integer> positionMap) {
        this.positionMap = positionMap;
        setUpdateOption();
    }

    public Map<Long, BigInteger> getPosAddSilverMap() {
        return posAddSilverMap;
    }

    public void setPosAddSilverMap(Map<Long, BigInteger> posAddSilverMap) {
        if (null == posAddSilverMap) {
            return;
        }
        this.posAddSilverMap = posAddSilverMap;
        setOp(DataStatus.Update);
    }

    public long getPosAddSilverTime() {
        return posAddSilverTime;
    }

    public void setPosAddSilverTime(long posAddSilverTime) {
        if (this.posAddSilverTime != posAddSilverTime) {
            this.posAddSilverTime = posAddSilverTime;
            setOp(DataStatus.Update);
        }
    }

    public long getZhanGong() {
        return zhanGong;
    }

    public void setZhanGong(long zhanGong) {
        if (this.zhanGong != zhanGong) {
            this.zhanGong = zhanGong;
            setOp(DataStatus.Update);
        }
    }

    public Map<Integer, Long> getZhanGongMap() {
        return zhanGongMap;
    }

    public void setZhanGongMap(Map<Integer, Long> zhanGongMap) {
        this.zhanGongMap = zhanGongMap;
        setUpdateOption();
    }

    public long getNeedHelpTime() {
        return needHelpTime;
    }

    public void setNeedHelpTime(long needHelpTime) {
        if (this.needHelpTime != needHelpTime) {
            this.needHelpTime = needHelpTime;
            setUpdateOption();
        }
    }

    public long getZhanGongTime() {
        return zhanGongTime;
    }

    public void setZhanGongTime(long zhanGongTime) {
        if (this.zhanGongTime != zhanGongTime) {
            this.zhanGongTime = zhanGongTime;
            setUpdateOption();
        }
    }

    public List<Long> getSoldierAddition() {
        return soldierAddition;
    }

    public void setSoldierAddition(List<Long> soldierAddition) {
        if (soldierAddition != null) {
            this.soldierAddition = soldierAddition;
            setUpdateOption();
        }
    }

    public Map<Integer, Long> getRedDotMap() {
        return redDotMap;
    }

    public void setRedDotMap(Map<Integer, Long> redDotMap) {
        if (redDotMap != null) {
            this.redDotMap = redDotMap;
            setUpdateOption();
        }
    }

    public int getHorseId() {
        return horseId;
    }

    public void setHorseId(int horseId) {
        if (this.horseId != horseId) {
            this.horseId = horseId;
            setUpdateOption();
        }
    }

    public int getGuide() {
        return guide;
    }

    public void setGuide(int guide) {
        if (this.guide != guide) {
            this.guide = guide;
            setUpdateOption();
        }
    }

    public BigInteger getTotalPosSilver() {
        return totalPosSilver;
    }

    public void setTotalPosSilver(BigInteger totalPosSilver) {
        if (null == totalPosSilver) {
            return;
        }
        if (!this.totalPosSilver.equals(totalPosSilver)) {
            this.totalPosSilver = totalPosSilver;
            setOp(DataStatus.Update);
        }
    }

    // ============= 不入库 =============

    public long getLastSyncPatronsTime() {
        return lastSyncPatronsTime;
    }

    public void setLastSyncPatronsTime(long lastSyncPatronsTime) {
        this.lastSyncPatronsTime = lastSyncPatronsTime;
    }

    public long getLastReqTime() {
        return lastReqTime;
    }

    public void setLastReqTime(long lastReqTime) {
        this.lastReqTime = lastReqTime;
    }

    public long getServerId() {
        return serverId;
    }

    public void setServerId(long serverId) {
        if(serverId != this.serverId){
            this.serverId = serverId;
            setUpdateOption();
        }
    }

    public int getChannelId() {
        return channelId;
    }

    public void setChannelId(int channelId) {
        if(channelId != this.channelId){
            this.channelId = channelId;
            setUpdateOption();
        }

    }
}
